﻿namespace Utility1
{
    using System;
    using System.IO;
    using System.Windows.Forms;

    public static class Write2Log
    {
        public static string LogFileName = "error.log";
        public static string LogFolder = Path.Combine(Application.StartupPath, "log");

        public static void WriteLogs(string sClassName, string sFunctionName, string sError)
        {
            try
            {
                if (!Directory.Exists(LogFolder))
                {
                    Directory.CreateDirectory(LogFolder);
                }
                StreamWriter writer = new StreamWriter(Path.Combine(LogFolder, LogFileName), true);
                writer.WriteLine("--------------------------------------------------------------------------------");
                writer.WriteLine("[Date & Time]\t\t" + DateTime.Now);
                writer.WriteLine("[Classes Name]\t\t" + sClassName.Trim());
                writer.WriteLine("[Functions Name]\t" + sFunctionName.Trim());
                writer.WriteLine("[Description Error]\t" + sError.Trim());
                writer.Flush();
                writer.Close();
            }
            catch
            {
            }
        }
    }
}

